#! /bin/bash

MMDETDIR='/root/code/mmsegmentation/'

TAR='leftImg8bit_travaltest'
GT='gtFine.zip'
ALL='cityscapes.tar'

TMPDIR='/dev/shm/'
TARDIR='/group_share/cityscapes/'

DATADIR=$TMPDIR
GTDIR=$TMPDIR


# if tar exist
[ -e '/root/'$ALL ] && tar -xf '/root/'$ALL -C /dev/shm && exit 0

# else
cd $TARDIR

echo check $DATADIR'train'
[ -e $DATADIR'leftImg8bit/train' ] && echo $DATADIR'leftImg8bit/train' OK!
[ ! -e $DATADIR'leftImg8bit/train' ] && echo $DATADIR'leftImg8bit/train' NG! NOW UNZIP: \
    && time unzip -qn $TARDIR$TAR -d $DATADIR

echo check $DATADIR'val'
[ -e $DATADIR'leftImg8bit/val' ] && echo $DATADIR'leftImg8bit/val' OK!
[ ! -e $DATADIR'leftImg8bit/val' ] && echo $DATADIR'leftImg8bit/val' NG! NOW UNZIP: \
    && time unzip -qn $TARDIR$TAR -d $DATADIR

echo check $GTDIR'train'
[ -e $GTDIR'gtFine/train' ] && echo $GTDIR'gtFine/train' OK!
[ ! -e $GTDIR'gtFine/train' ] && echo $GTDIR'gtFine/train' NG! NOW UNZIP: \
    && time unzip -qn $TARDIR$GT -d $GTDIR

# mkdir -p /root/code/mmsegmentation/data/cityscapes
# ln -s /dev/shm/leftImg8bit /root/code/mmsegmentation/data/cityscapes/leftImg8bit
# ln -s /dev/shm/gtFine /root/code/mmsegmentation/data/cityscapes/gtFine
